package com.lin.filegraph.utils.parser.node;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 10:17
 */
public class JDirectoryNode extends JTreeNode {

    private String strDirName = null;//�������·����
    public JDirectoryNode(String filePath, String strDirName) {
        super(filePath, null);
        this.strDirName = strDirName;
    }

    public JProjectNode getProjectNode() {
        JTreeNode fatherNode = super.getFatherNode();
        if (fatherNode instanceof JProjectNode) {
            return (JProjectNode) fatherNode;
        } else {
            System.err.println("ERR");
            return null;
        }
    }

    public List<JPackageNode> getAllPackages() {
        List<JPackageNode> packageList = new ArrayList<JPackageNode>();
        List<? extends JTreeNode> tempList = super.getChildrenNodeList();
        for (JTreeNode basedNode : tempList) {
            if (basedNode instanceof JPackageNode) {
                JPackageNode fileNode = (JPackageNode) basedNode;
                packageList.add(fileNode);
            }
        }
        return packageList;
    }

    @Override
    public String toString() {
        return "[DirectoryNode] " + strDirName;
    }

    public String getStrDirName() {
        return strDirName;
    }

}
